#include "get_smoke.h"
#include "zlog.h"

#define PUT 24

void smoke_init()
{

	pinMode(PUT,INPUT);
}

int get_smoke(void)
{
	int       rv = 0;
	int       status;

        rv = wiringPiSetupGpio(); //设置编码方式为BCM编码
	if(rv == -1)
	{
		dzlog_error("smoke : seting wiringpi fail!\n");
		return -1;
	}

	smoke_init();

	//digitalWrite(PUT,HIGH);
        status = digitalRead(PUT);
        if(status)
	{

	        dzlog_info("No smoke was detected\n");	
		//没有烟雾
		return 0;
	}
        else
	{

		dzlog_info("Smoke detected\n");
		//有烟雾
		return 1;

	}
}
